package com.jiangyg.devtools.ui.table.cell;

import com.intellij.ui.components.JBCheckBox;
import com.intellij.ui.components.JBPanel;

import java.awt.*;
import java.awt.event.ItemListener;

/**
 * 类描述：复选框单元格组件
 *
 * @author jiangyg
 * @version 1.0
 * @date 2023年08月28日
 */
public class CheckBoxCellComponent extends JBPanel<CheckBoxCellComponent> {

    private final JBCheckBox checkBox = new JBCheckBox();

    public CheckBoxCellComponent() {
        super(new FlowLayout());
        add(checkBox);
    }

    public CheckBoxCellComponent(boolean selected) {
        super(new FlowLayout());
        setSelected(selected);
        add(checkBox);
    }

    public void setSelected(boolean selected) {
        checkBox.setSelected(selected);
    }

    public boolean isSelected() {
        return checkBox.isSelected();
    }

    public void addItemListener(ItemListener listener) {
        checkBox.addItemListener(listener);
    }

}
